﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DiagramDesigner
{
    /// <summary>
    /// Interaction logic for CustomCommandUse.xaml
    /// </summary>
    public partial class GUICriterion: UserControl
    {
        public DesignerItem DesigItem
        {
            get;
            set;
        }
        public string Criterio
        {
            get;
            set;
        }
        public GUICriterion()
        {
            InitializeComponent();
            
            //listview.Items.Add("Nombre");
            //listview.Items.Add("Apellido");
            //listview.Items.Add("Direccion");
            //listview.Items.Add("Edad");           
        }

        private void OnAddListItemExecute(object sender, ExecutedRoutedEventArgs e)
        {
            ListView lv = sender as ListView;
            if (lv != null)
            {
                lv.Items.Add(e.Parameter);
                //txtItem.Clear();
                e.Handled = true;
            }
        }

        private void OnRemoveListItemExecute(object sender, ExecutedRoutedEventArgs e)
        {
            ListView lv = sender as ListView;
            if (lv != null)
            {
                if (lv.SelectedItem != null)
                {
                    lv.Items.Remove(lv.SelectedItem);
                    e.Handled = true;
                }
            }
        }

        private void CanAddListItemExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;// !String.IsNullOrEmpty(txtItem.Text) && !listview.Items.Contains(txtItem.Text);
            e.Handled = true;
        }

        private void CanRemoveListItemExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            ListView lv = sender as ListView;
            if (lv != null)
            {
                e.CanExecute = lv.SelectedItem != null;
                e.Handled = true;
            }
        }


    }
}
